package com.kws.merchant.controller;


import com.kws.merchant.domain.AfterSalesHelp;
import com.kws.merchant.service.AfterSalesHelpService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.kws.common.core.domain.R;

import javax.annotation.Resource;
import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

/**
 * 售后-帮助中心(AfterSalesHelp)表控制层
 *
 * @author yxy
 * @since 2024-10-22 19:23:09
 */
@RestController
@Api(tags = "售后-帮助中心(AfterSalesHelp)")
@RequestMapping("afterSalesHelp")
public class AfterSalesHelpController {
    /**
     * 服务对象
     */
    @Resource
    private AfterSalesHelpService afterSalesHelpService;

    @GetMapping("/getHelp")
    @ApiOperation("查询所有问题和答案")
    public R<List<AfterSalesHelp>> getHelp(){
        return R.ok(afterSalesHelpService.getHelp());
    }

    @GetMapping("/listByPid/{pid}")
    @ApiOperation(value = "通过pid查询所有数据")
    public R<List<AfterSalesHelp>> listByPid(@PathVariable Long pid){
        return R.ok(afterSalesHelpService.listByPid(pid));
    }

    @GetMapping("/detailById/{id}")
    @ApiOperation(value = "通过主键查询单条数据")
    public R<AfterSalesHelp> detailById(@PathVariable Integer id) {
        return R.ok(afterSalesHelpService.getById(id));
    }


    @PostMapping("/add")
    @ApiOperation(value = "新增数据")
    public R add(@RequestBody AfterSalesHelp afterSalesHelp) {
        return R.ok(afterSalesHelpService.save(afterSalesHelp));
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改数据")
    public R update(@RequestBody AfterSalesHelp afterSalesHelp) {
        return R.ok(afterSalesHelpService.updateById(afterSalesHelp));
    }


    @PostMapping("/delete")
    @ApiOperation(value = "删除数据")
    public R delete(@RequestBody List<Integer> idList) {
        return R.ok(afterSalesHelpService.removeByIds(idList));
    }

    @GetMapping("/listByQuestion/{question}")
    @ApiOperation(value = "模糊查询问题")
    public R<List<AfterSalesHelp>> listByQuestion(@PathVariable String question){
        return R.ok(afterSalesHelpService.listByQuestion(question));
    }

}
